/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package justdoit.view;

import javax.swing.JOptionPane;
import justdoit.Startup;
import justdoit.controller.TaskManager;
import justdoit.model.Task;
import justdoit.controller.LanguageManager;

/**
 * The Task Dialog for Creating a New Task. Inherited from TaskDialog.
 * @author Can
 */
public class NewTaskDialog extends TaskDialog {

    public NewTaskDialog() {
        super(LanguageManager.getString("title.addNewTask"));
    }

    @Override
    protected void okAction() {
        if (validation() < 0) {
            return;
        }
        if (TaskManager.addTask(getTaskFromInterface(new Task())) == 0) {
            System.out.println("add task success!");
            Startup.getMainFrame().getTaskListPanel().refreshData();
        } else {
            JOptionPane.showMessageDialog(null,
                    LanguageManager.getString("messageDialog.addNewTaskFail"));
        }
        this.dispose();
    }
}
